package com.my.app.tools.pojo.em.client;

import com.baidu.aip.ocr.AipOcr;
import com.my.app.tools.core.service.common.AppConfigService;

public enum OcrClientBaiDu {
    //
    INSTANCE(),
    ;
    private AipOcr client;

    private OcrClientBaiDu() {
        initClient();
    }

    public void initClient() {
        String appId = AppConfigService.readStringConfig("/app-config/ocr-api/baidu/api-id");
        String apiKey = AppConfigService.readStringConfig("/app-config/ocr-api/baidu/api-key");
        String secretKey = AppConfigService.readStringConfig("/app-config/ocr-api/baidu/secret-key");
        client = new AipOcr(appId, apiKey, secretKey);
        client.setConnectionTimeoutInMillis(2000);
        client.setSocketTimeoutInMillis(10000);
    }

    public AipOcr getClient() {
        return client;
    }
}
